package cn.rbac.action;

import java.util.List;

import cn.rbac.model.Resource;
import cn.rbac.model.User;
import cn.rbac.service.LoginService;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{
	private LoginService loginService=new LoginService();
	private IndexAction indexAction=new IndexAction();
	private User user;
	

	@Override
	public String execute() throws Exception {
		return LOGIN;
	}

	public String login(){
		if (user==null) {
			return ERROR;
		}
		user=loginService.userLogin(user);
		if(user!=null){
			return SUCCESS;
		}else{
			addFieldError("errMsg", "登录失败!请输入正确的用户名和密码!");
			return ERROR;
		}
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	

}
